@media (prefers-color-scheme: dark) {
  html {
    background-color: #002b36;
  }

  html[data-theme='light'] {
    background-color: transparent;
  }
}

@supports (font-variation-settings: normal) {
  html {
    font-family: 'Inter var', sans-serif;
  }
}

html:not(.is-native-android) {
  font-family: var(--ls-font-family), sans-serif, system-ui, -apple-system,
  BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',
  serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol !important;
}

/* region Reset top elements */
html {
  overflow: hidden;
}

body {
  color: var(--lx-gray-12, var(--ls-primary-text-color, hsl(var(--foreground))));
  background-color: var(--lx-gray-01, var(--ls-primary-background-color, hsl(var(--background))));
  line-height: 1.5;
  min-height: 100%;
  word-break: break-word; /* compatible for overflow-wrap: anywhere */
}

@layer base {
  svg {
    pointer-events: none;
  }

  textarea {
    overflow: hidden;
    padding: 8px;
    border: 1px solid rgba(39, 41, 43, 0.15);
    border-radius: var(--ls-border-radius-low);
    font-size: 1em;
    line-height: 1.5;
    width: 100%;
    resize: none;
    outline: none;
    font-weight: inherit;
    letter-spacing: inherit;
    text-size-adjust: 100%;
    background: var(--ls-primary-background-color);
  }

  ul {
    list-style: circle;
    margin-left: 1.2em;
  }

  ol {
    list-style: decimal;
    margin-left: 1.2em;
  }

  p {
    line-height: 1.5;
    margin: 0.5rem 0;
    color: var(--ls-primary-text-color);
  }

  li {
    margin: 0.25rem 0;
  }

  pre {
    background: var(--ls-secondary-background-color, #f6f8fa);
    margin: 1rem 0;
    line-height: 1.45em;
    overflow: auto;
  }

  a {
    cursor: pointer;
    color: var(--lx-accent-11, var(--ls-link-text-color, hsl(var(--primary)/.8)));
    text-decoration: none;
  }

  a:hover {
    color: var(--lx-accent-12, var(--ls-link-text-hover-color, hsl(var(--primary))));
  }

  code {
    font-size: 85%;
  }

  pre.code {
    background: #282a36;
    background: var(--ls-secondary-background-color);
    color: var(--ls-primary-text-color, #f8f8f2);
  }

  dl {
    margin: 1rem 0;
  }

  dt {
    margin-bottom: 0.25rem;
    font-weight: bold;
  }

  blockquote {
    display: block;
    text-indent: 0;
    padding: 8px 20px;
    border-left: 4px solid;
    border-left-color: var(--ls-page-blockquote-border-color, hsl(var(--primary)/.4));
    background-color: var(--ls-page-blockquote-bg-color, hsl(var(--secondary)));
    color: var(--ls-page-blockquote-color, hsl(var(--secondary-foreground)));
    margin: 1rem 0;
    font-size: 1rem;
  }

  summary {
    outline: none;
  }

  iframe {
    width: 100%;
    margin: 1rem 0;
  }

  img,
  video {
    margin-left: auto;
    margin-right: auto;
  }

  ::selection {
    background: var(--ls-selection-background-color);
    color: var(--ls-primary-text-color);
  }

  ::-moz-selection {
    background: var(--ls-selection-background-color);
    color: var(--ls-primary-text-color);
  }
}
/* endregion */

/** region App utilities **/
.ls-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

li p:first-child,
.block-body p:first-child {
  margin-top: 0;
}

li p:last-child,
.block-body p:last-child,
.block-body ul:last-child,
.block-body ol:last-child,
.block-body dl:last-child {
  margin-bottom: 0;
}

.bg-base-2 {
  background-color: var(--ls-secondary-background-color, #f0f8ff);
}

.bg-base-3 {
  background-color: var(--ls-primary-background-color, #fff);
}

.bg-base-4 {
  background-color: var(--ls-tertiary-background-color);
}

.pre-white-space {
  white-space: pre;
}

.pre-wrap-white-space {
  white-space: pre-wrap;
}

.pre-line-white-space {
  white-space: pre-line;
}

.cursor-pointer,
.cursor {
  cursor: pointer;
}

.external-link {
  text-decoration: none;
  border-bottom: 1px solid;

  &:hover {
    cursor: alias;
  }
}

.noscroll {
  position: fixed;
  overflow-y: scroll;
}

.canceled,
.cancelled,
.done {
  text-decoration: line-through;
  opacity: 0.6;
}

.opacity-30 {
  opacity: 0.3;
}

.opacity-70 {
  opacity: 0.7;
}

.opacity-80 {
  opacity: 0.8;
}

.done > input {
  opacity: 1;
}

.page-drop-options {
  width: 18em;
}

.fixed-width {
  max-width: calc(var(--ls-main-content-max-width) - 30px);
}

.center,
.foldable-title {
  margin: 0 auto;
}

.translate-x-5 {
  --transform-translate-x: 1.25rem;
}

.done,
.canceled,
.cancelled {
  opacity: 0.7;
}

.tip-shadow {
  -webkit-filter: drop-shadow(1px 1px 2px rgba(155, 155, 0, 0.8));
  filter: drop-shadow(1px 1px 2px rgba(155, 155, 0, 0.8));
}

.admonition-icon {
  @apply border-r;
}

i.ti {
  /*
  compensates the wrong top spacing in the iconfont.
  See https://github.com/tabler/tabler-icons/issues/118/
  */
  transform: translateY(-1px);
}

.dnd-separator {
  border-bottom: 3px solid #ccc;
}

.aspect-ratio-square {
  padding-top: 100%;
}

.aspect-ratio-16\/9 {
  padding-top: 56.25%;
}

.aspect-ratio-4\/3 {
  padding-top: 75%;
}

.aspect-ratio-21\/9 {
  padding-top: 42.86%;
}

.admonitionblock {
  margin: 2rem 0;
}

.abstract {
  margin: 2rem 0;
  width: 80%;
  font-style: italic;
}

.abstract p:last-of-type::before {
  content: '    ';
  white-space: pre;
}

.dropdown-overflow-auto {
  max-height: 400px;
  overflow-y: auto;
}

.heading-bg {
  border-radius: 50%;
  width: 18px;
  height: 18px;

  &.remove {
    @apply border flex items-center justify-center;

    border-color: var(--border-color);
  }
}

.to-heading-button {
  @apply px-1 text-lg !important;
}

/** endregion **/

/* region FIXME: override elements (?) */
h1.title, h1.title input {
  @apply mb-4 font-medium;

  color: var(--lx-gray-12, var(--ls-title-text-color, hsl(var(--foreground))));
  font-size: var(--ls-page-title-size, 32px);
}

.title .page-icon {
  margin-right: 12px;
}

.block-highlight,
.content .selected {
  transition: background-color 0.2s cubic-bezier(0, 1, 0, 1);
  background-color: var(--ls-block-highlight-color, var(--rx-gray-04));
  padding: -1px;
}

span.timestamp {
  margin: 0 0.25rem;
}

span.priority {
  color: #6b7280;
}

.form-checkbox:not(:checked):focus {
  box-shadow: none;
}

.form-checkbox:checked:focus {
  box-shadow: none;
}

a.nav-item:hover,
a.star-page:hover {
  background-color: #00242d;
}

button.menu {
  border-right: 1px solid;
  border-right-color: var(--ls-secondary-background-color, #f0f8ff);
  color: var(--ls-link-text-color, #24292e);
}

.menu-link:hover,
button.pull:hover,
button.menu:focus {
  background-color: or(--lx-gray-05, --ls-menu-hover-color, --rx-gray-05);
}

.menu-links-wrapper,
.menu-links-outer {
  @apply py-2 rounded-md shadow-lg overflow-y-auto border bg-popover min-w-[12rem];

  max-height: calc(100vh - 100px) !important;
}

.menu-backdrop {
  @apply w-full h-full fixed top-0 left-0;

  z-index: var(--ls-z-index-level-1);
}

.menu-link {
  @apply text-popover-foreground/75 select-none hover:text-popover-foreground/100;
  @apply text-sm px-2 py-1.5 mx-1 hover:rounded transition-opacity duration-150;
}

.menu-separator {
  @apply my-1 opacity-50 border-t;
}

a.login {
  color: var(--ls-link-text-color, #444);
}

a.login:hover {
  color: var(--ls-link-text-hover-color, #000);
}

a.tooltip-priority {
  display: contents;
  position: absolute;
  left: 0;
}

a.tooltip-priority::after {
  content: attr(priority);
  margin-right: 10px;
}

a.chosen {
  background: var(--ls-a-chosen-bg);
}

a.warning,
span.warning,
div.warning:not(.admonitionblock),
p.warning {
  background: var(--ls-warning-background-color);
  padding: 0.1em 0.4em;
  border-radius: var(--ls-border-radius-low);
  color: var(--ls-warning-text-color);
}

.text-warning {
  color: var(--ls-warning-text-color);
}

.bg-warning {
  background: var(--ls-warning-background-color);
}

a.error,
span.error {
  background: var(--ls-error-background-color);
  padding: 0.1em 0.4em;
  border-radius: var(--ls-border-radius-low);
  color: var(--ls-error-text-color);
}

.text-error {
  color: var(--ls-error-text-color);
}

.bg-error {
  background: var(--ls-error-background-color);
}

.text-success {
  color: var(--ls-success-text-color);
}

.bg-success {
  background: var(--ls-success-background-color);
}

img.small {
  display: inline;
  width: 20px;
  height: 20px;
  margin-top: 0;
  margin-bottom: 0;
}

a.tag {
  font-size: 0.9em;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 4px;
  color: var(--lx-accent-11, var(--ls-tag-text-color, hsl(var(--primary))));
  opacity: var(--ls-tag-text-opacity, 0.7);
}

a.tag:hover {
  opacity: var(--ls-tag-text-hover-opacity, 1);
  text-decoration: underline;
}

svg.note {
  color: var(--rx-yellow-08);
}

svg.tip {
  color: var(--lx-accent-08, var(--rx-blue-08));
}

/* endregion */

/* region FIXME: CodeMirror override (?) */
.CodeMirror pre.CodeMirror-line,
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
  font-size: 14px;
}

/* endregion */

hr {
  margin: 2rem 0;
  border-color: var(--lx-gray-05, var(--ls-border-color, var(--rx-gray-05)));
}

.resize {
  resize: both;
  overflow: hidden;
  max-width: -webkit-fill-available;
}

/* ideas from https://github.com/PiotrSss/logseq-bujo-theme/blob/main/main.css */

/***************************************************************
***************************** TOP ******************************
***************************************************************/

.cp__header-logo,
.fade-link {
  opacity: 0.8;
  transition: 0.3s;
  color: var(--ls-primary-text-color);
}

a.fade-link:hover {
  opacity: 1;
}

/* import (arrows) icon */

#head .refresh svg {
  height: 20px;
}

.svg-small svg {
  transform: scale(0.6);
  display: inline;
}

/* < > buttons */

a.navigation {
  border-radius: 3px;
  transition: 0.3s;
}

/* text mark/highlight */

mark {
  background: var(--ls-page-mark-bg-color, #fef3ac);
  color: var(--ls-page-mark-color, #262626);
  padding: 2px 4px;
  border-radius: 3px;
}

/* page reference */

.page-reference {
  border-radius: 3px;
  padding: 2px 0px;
  transition: 0.3s;
}

.page-reference .bracket {
  opacity: 0.3;
}

/* block references */
.block-ref .block-ref {
  padding: 6px 5px;
  border: none;
}

/* inline code */
:not(pre) > code {
  border-radius: 3px;
  font-size: 0.9em;
  font-style: normal;
  font-family: MonoLisa, 'Fira Code', Monaco, Menlo, Consolas, 'COURIER NEW',
  monospace;
  letter-spacing: 0;
  background-color: var(--lx-gray-06, var(--ls-page-inline-code-bg-color, var(--rx-gray-05)));
  color: var(--lx-gray-11, var(--ls-page-inline-code-color, var(--rx-gray-11)));
  text-rendering: optimizeSpeed;
}

:not(pre):not(mark) > code {
  line-height: 1.45;
  padding: 3px 5px !important;
  border-radius: var(--ls-border-radius-low);
  -webkit-border-radius: var(--ls-border-radius-low);
}

mark > code {
  padding: 0;
  line-height: inherit !important;
  background: #fef3ac !important;
  color: #262626 !important;
}

b > code {
  font-weight: bold !important;
}

i > code {
  font-style: italic !important;
}

a {
  transition: 0.3s;
}

a.tooltip-priority {
  transition: none;
}

.page-reference:hover {
  background: var(--lx-accent-04-alpha, var(--ls-secondary-background-color, hsl(var(--primary)/.4)));
}

.references-blocks .page-reference:hover {
  background: var(--lx-accent-04-alpha, var(--ls-tertiary-background-color, hsl(var(--primary)/.4)));
}

#head .fade-link {
  font-weight: 600;
  font-size: 13px;
}

.text-link {
  color: var(--ls-primary-text-color);
}

.katex * {
  border-color: var(--ls-primary-text-color);
}

#help-latex .katex-html {
  text-align: right;
}

a.page-op svg {
  transform: scale(0.9);
}

.search-more {
  background: var(--ls-a-chosen-bg);
}

.keyboard-shortcut > code {
  margin: 2px;
  background-color: var(--ls-quaternary-background-color);
  padding: 2px 4px !important;
  border-radius: 6px;
  color: var(--ls-secondary-text-color);
}

html[data-theme='light'] .keyboard-shortcut > code {
  box-shadow: inset 0 -1px 0 #433f3855, 0 0 1px 1px #433f3822;
}

html[data-theme='dark'] .keyboard-shortcut > code {
  box-shadow: inset 0 -1px 0 var(--ls-primary-background-color),
  0 0 1px 1px rgba(255, 255, 255, 0.2);
}

.ui__modal-panel {
  border-radius: 8px;
}

.overflow-y-scroll {
  overflow-y: scroll;
}

.text-ellipsis-wrapper {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lazy-visibility {
  min-width: 1px;
  min-height: 1px;
}

.katex .tag {
  overflow-x: clip;
}

html.is-mobile {
  h1.title {
    margin-bottom: 10px;
  }

  #journals .journal-item:first-child {
    margin-top: 5px;
  }

  main.theme-inner {
    @apply overflow-x-hidden;
  }
}

@layer base {
  .ls-grid-cols {
    @apply grid grid-flow-col auto-cols-max;
    place-items: center;
  }

  /* fixes an html2canvas issue */
  img {
    @apply inline-block;
  }
}
